﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;

namespace XGame.Input
{
    public class MouseController : GameComponent
    {
        private MouseState currentMouseState;
        private MouseState previouseMouseState;

        public event EventHandler<EventArgs> rightMousePressed;
        public event EventHandler<EventArgs> rightMouseReleased;

        public event EventHandler<EventArgs> leftMousePressed;
        public event EventHandler<EventArgs> leftMouseReleased;

        public event EventHandler<EventArgs> centerMousePressed;
        public event EventHandler<EventArgs> centerMouseReleased;


        public Vector2 MousePosition
        {
            get { return mousePosition; }
        }


        private Vector2 mousePosition;


        public MouseController(Game game):base(game)
        {
            
            
        }

        public override void Initialize()
        {
            

            base.Initialize();
        }

        public override void Update(GameTime gameTime)
        {
            currentMouseState = Mouse.GetState();

            if (currentMouseState.LeftButton == ButtonState.Pressed && previouseMouseState.LeftButton == ButtonState.Released)
            {
                
               
                    //throw left pressed event here
                
            }

            if (currentMouseState.LeftButton == ButtonState.Released && previouseMouseState.LeftButton == ButtonState.Pressed)
            {
                //throw left released event here
            }

            if (currentMouseState.RightButton == ButtonState.Pressed && previouseMouseState.RightButton == ButtonState.Released)
            {


                //throw right pressed event here

            }

            if (currentMouseState.MiddleButton == ButtonState.Released && previouseMouseState.MiddleButton == ButtonState.Pressed)
            {
                //throw center released event here
            }

            if (currentMouseState.MiddleButton == ButtonState.Released && previouseMouseState.MiddleButton == ButtonState.Pressed)
            {
                //throw center released event here
            }

            mousePosition.X = (float)currentMouseState.X;
            mousePosition.Y = (float)currentMouseState.Y;

            



            previouseMouseState = currentMouseState;

            base.Update(gameTime);
        }


    }
}
